﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace e3
{
    public partial class Form1 : Form
    {

        string file1 = "未选择";
        string content1 = "";
        string file2 = "未选择";
        string content2 = "";
        string file3 = "E:/";
        string context3 = "";
        public Form1()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "文本文件(*.txt) | *.txt | 所有文件(*.*) | *.*";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
                file1 = openFileDialog.FileName;
            textBox1.Text = file1;

            StreamReader sr = new StreamReader(file1, Encoding.Default);
            content1 = sr.ReadToEnd();
            textBox12.Text = content1;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "文本文件(*.txt) | *.txt | 所有文件(*.*) | *.*";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
                file2 = openFileDialog.FileName;
            textBox2.Text = file2;

            StreamReader sr = new StreamReader(file1, Encoding.Default);
            content2 = sr.ReadToEnd();
            textBox22.Text = content1;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFile = new SaveFileDialog();
            saveFile.Title = "请选择保存文件路径";
            saveFile.Filter = "文本文件(*.txt) | *.txt | 所有文件(*.*) | *.*";
            saveFile.OverwritePrompt = true;  
            saveFile.RestoreDirectory = true;  
            if (saveFile.ShowDialog() == DialogResult.OK)
            {
                file3 = saveFile.FileName;
            }

            context3 = content1 + content2;
            using (StreamWriter sw = new StreamWriter(file3))
            { sw.WriteLine(context3); }
        }
    }
}
